package com.example.royalchef.activity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.royalchef.R;
import com.example.royalchef.bean.PushItem;
import com.example.royalchef.utils.UIUtils;
import com.squareup.picasso.Picasso;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * author: Administrator
 * created on: 2017/7/6 14:29
 * description:
 */

public class PushDetailActivity extends AppCompatActivity {
    @BindView(R.id.tv_push_detail_title)
    TextView tvTitle;
    @BindView(R.id.iv_push_detail_picture)
    ImageView ivPicture;
    @BindView(R.id.tv_push_detail_content)
    TextView tvContent;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_push_detail);
        ButterKnife.bind(this);
        initData();
    }

    private void initData() {
        Intent intent = getIntent();
        PushItem pushitem = (PushItem) intent.getParcelableExtra("pushitem");
        tvTitle.setText(pushitem.getTitle());
        tvContent.setText(pushitem.getContent());
        int width = this.getWindowManager().getDefaultDisplay().getWidth();
        Picasso.with(PushDetailActivity.this)
                .load(pushitem.getCover())
                .resize(width, UIUtils.dip2px(200))
                .centerCrop()
                .config(Bitmap.Config.RGB_565)
                .into(ivPicture);
    }
}
